package com.wenwan.manage.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wenwan.manage.service.GoodsVolumeShareService;
import com.wenwan.manage.setting.DefaultValue;

import javax.annotation.Resource;

/**
 * 商品分享量
 * 
 * @author Admin
 *
 */
@Controller
@RequestMapping(value = "/goods/volume/share", method = { RequestMethod.POST })
public class GoodsVolumeShareController {

	@Autowired
	private GoodsVolumeShareService goodsVolumeShareService;

	@ResponseBody
	@RequestMapping(value = "/create", method = { RequestMethod.POST })
	public Map<String,Object> create(@RequestParam(required = true) String goodsId,
			@RequestParam(required = true) String userId) {
		return goodsVolumeShareService.create(goodsId, userId);
	}

	@ResponseBody
	@RequestMapping(value = "/delete/by/id", method = { RequestMethod.POST })
	public Map<String,Object> deleteById(@RequestParam(required = true) String id) {
		return goodsVolumeShareService.deleteById(id);
	}

	// @ResponseBody
	// @RequestMapping(value = "/update", method = { RequestMethod.POST })
	public Map<String,Object> update(@RequestParam(required = true) String id,
			@RequestParam(required = true) String goodsId, @RequestParam(required = true) String userId) {
		return goodsVolumeShareService.update(id, goodsId, userId);
	}

	@ResponseBody
	@RequestMapping(value = "/select/all", method = { RequestMethod.GET })
	public Map<String,Object> selectAll(
			@RequestParam(required = false, defaultValue = DefaultValue.CURRENT_PAGE) Integer currentPage,
			@RequestParam(required = false, defaultValue = DefaultValue.PAGE_SIZE) Integer pageSize) {
		return goodsVolumeShareService.selectAll(currentPage, pageSize);
	}

	@ResponseBody
	@RequestMapping(value = "/select/one/by/id", method = { RequestMethod.GET })
	public Map<String,Object> selectOneById(@RequestParam(required = true) String id) {
		return goodsVolumeShareService.selectOneById(id);
	}

}
